Conversation
| <> | ||
| <IconButton | ||
| icon="format-bold" | ||
| selected={value === 'bold'} |
There was a problem hiding this comment.
Following this loses the selected state for screen readers: IconButton's selected only changes colours, while ToggleButton passed aria-selected through. Worth adding aria-selected to the snippet, or having IconButton derive it from selected?
There was a problem hiding this comment.
@JKobrynski, thank you for the comment! I've updated the migration docs with aria-selected.
As for deriving it from the selected one on the IconButton, I don't think that's in scope for this PR.
I can create a separate PR for it, or we can add it as a part of the IconButton modernization to MD3 (when that PR will be ready)
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved accessibility and migration-behavior findings remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Removes the obsolete ToggleButton component family from v6 and updates examples and documentation to use current alternatives.
Changes:
- Removes implementations, exports, tests, and snapshots.
- Replaces tooltip controls and removes the obsolete example.
- Updates documentation registrations and adds migration guidance.
Open findings include migration behavior and accessibility issues, plus stale screenshot assets.
File summaries
| File | Description |
|---|---|
src/index.tsx |
Removes public component and type exports. |
src/components/ToggleButton/utils.ts |
Removes toggle-specific utilities. |
src/components/ToggleButton/ToggleButtonRow.tsx |
Removes row implementation. |
src/components/ToggleButton/ToggleButtonGroup.tsx |
Removes group implementation. |
src/components/ToggleButton/ToggleButton.tsx |
Removes base implementation. |
src/components/ToggleButton/index.ts |
Removes compound exports. |
src/components/__tests__/ToggleButton.test.tsx |
Removes obsolete tests. |
src/components/__tests__/__snapshots__/ToggleButton.test.tsx.snap |
Removes obsolete snapshot. |
example/src/Examples/TooltipExample.tsx |
Replaces controls with IconButton. |
example/src/Examples/ToggleButtonExample.tsx |
Removes obsolete example. |
example/src/ExampleList.tsx |
Removes example registration. |
docs/src/data/screenshots.ts |
Removes screenshot mappings. |
docs/component-docs.config.ts |
Removes documentation entries. |
docs/6.x/docs/guides/migration.md |
Adds migration guidance. |
Review details
Suppressed comments (5)
docs/6.x/docs/guides/migration.md:351
- The removed ToggleButton group cleared the value when its already-selected item was pressed (
!checked ? value : null). This replacement always writes'bold', so copying the migration changes the behavior by making the active option impossible to deselect; preserve the null transition or explicitly document that behavior change.
onPress={() => setValue('bold')}
docs/src/data/screenshots.ts:151
- Removing the active screenshot mappings leaves the corresponding top-level assets (
docs/public/screenshots/toggle-button.png,toggle-button-group.gif,toggle-button-row.gif, anddocs/public/gallery/toggle-button.png) checked in but unreferenced. These are outside the versioned archived pages, so please remove the orphaned assets as part of the component removal to avoid carrying stale documentation files.
},
example/src/Examples/TooltipExample.tsx:99
selectedonly changes IconButton's visual colors; it does not derive an accessibility state. This replacement therefore leaves the active alignment unavailable to screen readers, unlike the migration example below; pass the matchingaria-selectedvalue on this button (and the other two buttons).
selected={textAlign === 'left'}
example/src/Examples/TooltipExample.tsx:107
- This selected alignment control also omits
aria-selected, so assistive technology cannot identify the active option. Add the matching accessibility state here as well as on the other icon toggles.
selected={textAlign === 'center'}
example/src/Examples/TooltipExample.tsx:115
- The disabled alignment control still represents a selected state, but
selectedis not exposed to assistive technology by IconButton. Addaria-selectedhere too so this replacement has consistent state semantics.
selected={textAlign === 'right'}
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| aria-selected={value === 'bold'} | ||
| /> | ||
| <IconButton | ||
| icon="format-italic" | ||
| selected={value === 'italic'} | ||
| onPress={() => setValue('italic')} | ||
| aria-selected={value === 'italic'} |
Motivation
ToggleButtonpredates the Material Design 3 work and has no place in the v6component set. MD3 has no equivalent component, and both of its use cases are
already covered by components we keep:
IconButtonwithselectedSegmentedButtonsIt is removed outright, with no deprecation alias and no runtime warning, per
the v6 rule against deprecations.
What's removed
ToggleButton,ToggleButton.Group,ToggleButton.Row, and theirutilsToggleButtonProps,ToggleButtonGroupPropsandToggleButtonRowPropsdocs/component-docs.config.tsanddocs/src/data/screenshots.ts, which drive 6.x doc generationMigration
Documented in
docs/6.x/docs/guides/migration.md:Its line in the guide's animated-style list is gone too, since the component no
longer exists to accept a
style.Notes for review
Buttonalso gains aselectedprop as part of its MD3 update. That proparrives with refactor(button): improve MD3 compliance and modernize content API #4928, so if this lands first the sentence describes a prop not
yet on
main. It reads as forward-looking rather than wrong, but it is wortha look if the two land far apart. Every code example in the entry uses only
APIs that exist on
maintoday.Test plan
yarn test,yarn lint,yarn typecheckpass: 54 suites, 669 tests, 1skipped, no obsolete snapshots.
tsc -p example --noEmit).yarn buildindocs/succeeds, and the built output has no 6.xToggleButton page while the archived older-version pages are unchanged.
intentional migration entry and the 5.x docs.
BREAKING CHANGE:
ToggleButton,ToggleButton.GroupandToggleButton.Roware removed, along with
ToggleButtonProps,ToggleButtonGroupPropsandToggleButtonRowProps. UseIconButtonwithselectedfor an icon-onlytoggle, or
SegmentedButtonsfor a set of mutually exclusive options.